package com.qr.backend.mapper;

import com.qr.backend.entity.Account;
import com.qr.backend.response.AccountUserResponse;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author : jinxiaobo
 * @date : 2023年12月19日 11:20:10
 * @description : 用户mapper
 */
@Mapper
public interface UserMapper {
    //根据用户名或者邮箱获取用户信息
    @Select("select * from db_account where username = #{userNameOrEmail} or email = #{userNameOrEmail}")
    Account findAccountByNameOrEmail(String userNameOrEmail);

    @Select("select * from db_account where username = #{userNameOrEmail} or email = #{userNameOrEmail}")
    AccountUserResponse findAccountUserNameOrEmail(String userNameOrEmail);

    @Insert("insert into db_account (email,username,password) values (#{email},#{username},#{password})")
    int createAccount(String username, String password, String email);

    @Update("update db_account set password = #{password} where email = #{email}")
    int resetPassWord(String password, String email);
}
